package com.hmdp.service.impl;

import com.hmdp.dto.Result;
import com.hmdp.dto.UserDTO;
import com.hmdp.entity.BlogComments;
import com.hmdp.entity.ShopComments;
import com.hmdp.mapper.BlogCommentsMapper;
import com.hmdp.service.IBlogCommentsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hmdp.utils.UserHolder;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 虎哥
 * @since 2021-12-22
 */
@Service
public class BlogCommentsServiceImpl extends ServiceImpl<BlogCommentsMapper, BlogComments> implements IBlogCommentsService {

    @Override
    public Result saveComments(BlogComments shop) {
         // 1.获取登录用户
        UserDTO user = UserHolder.getUser();
        shop.setUserId(user.getId());
        // 2.保存探店笔记
        boolean isSuccess = save(shop);
        if (!isSuccess) {
            return Result.fail("新增评论失败!");
        }
        return Result.ok(shop.getBlogId());
    }
}
